package com.hw.paltfrom.controller.system;
import com.hw.paltfrom.pack.ResponseResult;
import com.hw.paltfrom.rescode.HWSystemCode;
import com.hw.paltfrom.service.system.BaseAreaServer;
import com.hw.paltfrom.service.system.BaseUserServer;
import com.hw.paltfrom.utils.VerifyUtil;
import com.hw.paltfrom.vo.BaseUserVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Map;

/**
 * 系统用户
 * 崔孟超
 * 2019年11月6日15:19:51
 */
@RestController
@RequestMapping(value = "/BaseUserController")
public class BaseUserController {
    @Autowired
    private BaseUserServer baseUserServer;

    /**
     * 用户遍历+分页+模糊查询
     * @param vo
     * @return
     */
    @RequestMapping(value = "/queryAllList")
    public Map<String, Object> queryAllList(BaseUserVo vo) {
        Boolean flag = VerifyUtil.verifyParams(vo);
        if (!flag) {
            return ResponseResult.fail(HWSystemCode.PARAMS_ERROR);
        }
        return baseUserServer.queryAllList(vo);
    }


    /**
     * 用户的添加
     * @param vo
     * @return
     */
    @RequestMapping(value = "/add")
    public Map<String, Object> userAdd(BaseUserVo vo) {
        Boolean flag = VerifyUtil.verifyParams(vo);
        if (!flag) {
            return ResponseResult.fail(HWSystemCode.PARAMS_ERROR);
        }
        return baseUserServer.insert(vo);
    }

    /**
     * 用户的编辑修改
     * @param vo
     * @return
     */
    @RequestMapping(value = "/update")
    public Map<String, Object> userUpdate(BaseUserVo vo) {
        Boolean flag = VerifyUtil.verifyParams(vo);
        if (!flag) {
            return ResponseResult.fail(HWSystemCode.PARAMS_ERROR);
        }
        return baseUserServer.update(vo);
    }

    /**
     * 用户初使化
     *
     * @return
     */
    @RequestMapping(value = "/initIaLiZatIonUser")
    public Map<String, Object> initIaLiZatIonUser(BaseUserVo vo) {
        Boolean flag = VerifyUtil.verifyParams(vo);
        if (!flag) {
            return ResponseResult.fail(HWSystemCode.PARAMS_ERROR);
        }

        return baseUserServer.initIaLiZatIonUser(vo);
    }

    /**
     * 用户停用
     *
     * @return
     */
    @RequestMapping(value = "/diSaBleUser")
    public Map<String, Object> diSaBleUser(BaseUserVo vo) {
        Boolean flag = VerifyUtil.verifyParams(vo);
        if (!flag) {
            return ResponseResult.fail(HWSystemCode.PARAMS_ERROR);
        }
        return baseUserServer.diSaBleUser(vo);
    }

    /**
     * 详情+单个修改展示
     * @param
     * @return
     */
    @RequestMapping(value = "/particularsUser")
    public Map<String, Object> particularsUser() {
        return baseUserServer.particularsUser();
    }

    /**
     * popUpBox
     * @param vo
     * @return
     */
    @RequestMapping(value = "/popUpBox")
    public Map<String, Object> popUpBox(BaseUserVo vo) {
        Boolean flag = VerifyUtil.verifyParams(vo);
        if (!flag) {
            return ResponseResult.fail(HWSystemCode.PARAMS_ERROR);
        }
        return baseUserServer.popUpBox(vo);
    }

}
